package com.example.springboottest.config;

import com.example.springboottest.big3.CrazyitFilter;
import com.example.springboottest.big3.CrazyitListener;
import com.example.springboottest.big3.FirstServlet;
import com.example.springboottest.big3.SecondServlet;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpServlet;

//@Configuration(proxyBeanMethods = false)
@Configuration()
// 通过该注解设置到指定包中扫描Servlet、Filter、Listener
@ServletComponentScan("com.example.springboottest.big3.annotation")
public class Big3Config {
    @Bean("first")
    public HttpServlet createServlet1() {
        FirstServlet firstServlet = new FirstServlet();
        return firstServlet;
    }

    @Bean("second")
    public HttpServlet createServlet2() {
        SecondServlet secondServlet = new SecondServlet();
        return secondServlet;
    }

    @Bean
    public ServletContextListener createListener() {
        CrazyitListener listener = new CrazyitListener();
        return listener;
    }

    @Bean
    public Filter createFilter() {
        CrazyitFilter filter = new CrazyitFilter();
        return filter;
    }
}
